package org.eyeTopLight.service.impl;

import org.eyeTopLight.dao.CategoryDao;
import org.eyeTopLight.po.Category;
import org.eyeTopLight.exception.ErrorCode;
import org.eyeTopLight.exception.ExceptionHandler;
import org.eyeTopLight.service.CategoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class CategoryServiceImpl implements CategoryService {
    private static final Logger logger = LoggerFactory.getLogger(CategoryServiceImpl.class);

    @Resource
    CategoryDao categoryDao;
    /**
     * 获取首页轮播种类的所有分类和图标
     * @return
     */
    @Override
    public List<Category> getCategories(String symbol) {
        Category category = new Category();
        category.setCategory_symbol(symbol);
        List<Category> categoriesList = null;
        try {
            categoriesList = categoryDao.query(category);
        }catch (Exception e){
            logger.error("查询数据库Category表操作失败",e);
            ExceptionHandler.processError(ErrorCode.ERR_DB_SELECT.getValue(),"查询数据库Category表操作失败");
        }
        return categoriesList;
    }

}
